from pyecharts.charts import Map
from pyecharts.options import VisualMapOpts, TitleOpts, ToolboxOpts
map1 = Map()
data = [
    ("北京市", 5),
    ("内蒙古自治区", 5),
    ("新疆维吾尔自治区", 5),
    ("上海市", 50),
    ("湖南省", 366),
    ("广东省", 888),
    ("江苏省", 888),
    ("浙江省", 8888),
    ("河南省", 88888),
]
map1.add("测试地图", data, "china")
map1.set_global_opts(
    visualmap_opts=VisualMapOpts(
        is_show=True,
        is_piecewise=True,
        pieces=[
            {"min": 1, "max": 9, "label": "1-9人", "color": "#CCFFFF"},
            {"min": 10, "max": 99, "label": "10-99人", "color": "#FFFF99"},
            {"min": 100, "max": 499, "label": "100-4499人", "color": "#FF9966"},
            {"min": 500, "max": 999, "label": "500-999人", "color": "#FF6666"},
            {"min": 1000, "max": 9999, "label": "1000-999人", "color": "#CC3333"},
            {"min": 10000, "label": "10000以上", "color": "#990033"},
        ]
    ),
    title_opts=TitleOpts(title="疫情数据"),
    toolbox_opts=ToolboxOpts(is_show=True),
)
map1.render()
